#include <bits/stdc++.h>
using namespace std;
struct car
{
    int d,v,a;
    int spdmidle;
    int tester;
    car(int _d=0,int _v=0,int _a=0)
    {
        d=_d,v=_v,a=_a;
    }
    void input(int l,int spd)
    {
        cin >> d >> v >> a;
        spdmidle=(spd*spd-v*v);
    }
    bool tes(int l)
    {
        int ll=(l-d)*a*2;
        //cout << 'e' << ll << ' ' << spdmidle << ' ' << a <<' ' << l << ' ' << d << ' ';
        if((ll>spdmidle&&a||spdmidle<0&&!a)&&l>=d)
            return 1;
        return 0;
    }
    void test(int l)
    {
        if(tes(l))
            tester++;
    }
    bool detest(int l)
    {
        //cout << 't' << tester << ' '<< d << ' ' << v << ' ' << a << ' ' << spdmidle << ' ';
        if(tes(l))
            tester--;
        //cout <<l<<' '<<tes(l)<<' '<<tester<<' ';
        return bool(tester);
    }
    bool overspeeded()
    {
        return tester;
    }
    bool operator<(car another)
    {
        return tester>=another.tester;
    }
};
int DP(int* testers,int testern,car* cars,int carn)
{
    if(!testern)
        return 0;
    //cout <<"use";
    int tmp=DP(testers+1,testern-1,cars,carn);
    int i=0;
    for(; i<carn; i++)
    {
        if(!cars[i].detest(testers[0]))
        {
            //cout << i << "cant remove tester" << testers[0] << ' ';
            break;
        }

    }
    //cout << tmp << ' ' << i << endl;;
    if(i==carn)
        tmp=max(tmp,DP(testers+1,testern-1,cars,carn)+1);
    //cout << tmp << endl;
    for(int j=0; j<=i; j++)
    {
        cars[j].test(testers[0]);
    }
    //cout << "return";
    return tmp;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    cin >> t;
    int n=0,m=0,l=0,v=0;
    car cars[100005]= {};
    int spdtests[100005]= {};
    while(t--)
    {
        memset(cars,0,sizeof(cars));
        memset(spdtests,0,sizeof(spdtests));
        cin >> n >> m >> l >> v;

        for(int i=0; i<n; i++)
            cars[i].input(l,v);

        for(int i=0; i<m; i++)
        {
            cin >> spdtests[i];
            for(int j=0; j<n; j++)
                cars[j].test(spdtests[i]);
        }
        int overs=0;
        sort(cars,cars+n);
        /*for(int i=0; i<n; i++)
        {
            cout << cars[i].d << ' ' <<cars[i].v << ' ' <<cars[i].a<< ' ' <<cars[i].spdmidle<< ' ' <<cars[i].tester<<endl;
        }*/
        while(cars[overs].overspeeded())
            overs++;
        cout << overs << ' ' <<
             DP(spdtests,m,cars,overs) << endl;
    }
    return 0;
}
